{include file="public/header" /}
<div class="header">
    <a href="{$config.path}navigation/index"><span style="background: #999;">导航列表</span></a>
    <span>菜单列表</span>
    <button type="button" class="layui-btn layui-btn-sm" onclick="add()">
        <i class="layui-icon layui-icon-add-1"></i>添加
    </button>
    <div></div>
</div>
<table class="layui-table">
    <thead>
    <tr>
        <th>ID</th>
        <th>菜单名</th>
        <th>跳转url</th>
        <th>排序</th>
        <th>状态</th>
        <th>显示</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="lists" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.name}</td>
            <td>{$vo.url}</td>
            <td>{$vo.sort}</td>
            <td>
                {if ($vo.status == 1) }
                    开启
                {else /}
                    关闭
                {/if}
            </td>
            <td>
                {if ($vo.show == 1) }
                    是
                {else /}
                    否
                {/if} 
            </td>
            <td>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="edit({$vo.id})">
                    <i class="layui-icon">&#xe642;</i>编辑
                </button>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="del({$vo.id})">
                    <i class="layui-icon">&#xe640;</i>删除
                </button>
            </td>
        </tr>
    {/volist}
    </tbody>
</table>
<script type="text/javascript">
    layui.use(['layer'],function(){
        $ = layui.jquery;
    })
    function add(){
        layer.open({
            type:2,
            title:'添加菜单',
            shade:0.3,
            area: ['550px','500px'],
            content: '{$config.path}menu/add?pid={$pid}'
        })
    }
    function edit(id){
        layer.open({
            type:2,
            title:'修改菜单',
            shade:0.3,
            area: ['550px','500px'],
            content: '{$config.path}menu/edit?id=' + id
        })
    }
    function del(id){
        layer.confirm('您确定要删除吗？',{
                icon:3,
                btn: ['确定','取消']
            },function(){
                $.get('{$config.path}menu/delete?id=' + id,function(res){
                    if(res.error_code == 0){
                        layer.msg(res.msg, { 'icon': 1 });
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                    }else{
                        layer.msg(res.msg, { 'icon': 2 });
                    }
                },'json').error(function (res) {
                    layer.msg(res.responseJSON.msg, { 'icon': 2 });
                });
            })
    }
</script>
</body>
</html>